Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix formatting of trailing unescaped quotes in raw triple quoted strings #6202

Merged
merged 3 commits into from
Jul 31, 2023

Conversation

konstin
Copy link
Member

@konstin konstin commented Jul 31, 2023

Summary This prevents us from turning r'''\""''' into r"""\""""", which is invalid syntax.

This PR fixes CI, which is currently broken on main (in a way that still passes on linter PRs and allows merging formatter PRs, but it's bad to have a job be red). Once merged, i'll make the formatted ecosystem checks a required check.

Test Plan Added a regression test.

…ngs.

**Summary** This prevents us from turning `r'''\""'''` into `r"""\"""""`, which is invalid syntax.

This PR fixes CI, which is currently broken on main (in a way that still passes on linter PRs and allows merging formatter PRs, but it's bad to have a job be red). Once merged, i'll make the formatted ecosystem checks a required check.

**Test Plan** Added a regression test.
@konstin konstin changed the title Fix formatting of trailing unescaped quotes in raw triple quoted strings. Fix formatting of trailing unescaped quotes in raw triple quoted strings Jul 31, 2023
@konstin
Copy link
Member Author

konstin commented Jul 31, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

Comment on lines 327 to 329
// We can't turn `r'''\""'''` into `r"""\"""""`, the last previously inner quote
// we shorten the quoted part and turn the last triple quote char into an
// unterminated string start.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this comment. What I understand from the code is that the match now returns true for a single quote at the end of the string. What about a triple quoted string that ends with two quotes?
'''""'''

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, fixed

@konstin konstin added the formatter Related to the formatter label Jul 31, 2023
@github-actions
Copy link
Contributor

PR Check Results

Benchmark

Linux

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.00      8.5±0.09ms     4.8 MB/sec    1.01      8.6±0.09ms     4.7 MB/sec
formatter/numpy/ctypeslib.py               1.00  1670.9±23.81µs    10.0 MB/sec    1.00  1676.5±11.80µs     9.9 MB/sec
formatter/numpy/globals.py                 1.00    182.0±2.01µs    16.2 MB/sec    1.02    186.5±3.76µs    15.8 MB/sec
formatter/pydantic/types.py                1.00      3.6±0.07ms     7.1 MB/sec    1.00      3.6±0.03ms     7.1 MB/sec
linter/all-rules/large/dataset.py          1.00     11.2±0.06ms     3.6 MB/sec    1.01     11.3±0.05ms     3.6 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      2.8±0.01ms     5.9 MB/sec    1.00      2.8±0.02ms     5.9 MB/sec
linter/all-rules/numpy/globals.py          1.00    383.3±1.03µs     7.7 MB/sec    1.00    382.8±1.66µs     7.7 MB/sec
linter/all-rules/pydantic/types.py         1.00      5.0±0.04ms     5.1 MB/sec    1.01      5.1±0.08ms     5.0 MB/sec
linter/default-rules/large/dataset.py      1.00      6.0±0.03ms     6.8 MB/sec    1.01      6.0±0.05ms     6.8 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00   1241.8±1.94µs    13.4 MB/sec    1.00   1244.7±8.64µs    13.4 MB/sec
linter/default-rules/numpy/globals.py      1.00    135.8±0.19µs    21.7 MB/sec    1.00    136.1±0.61µs    21.7 MB/sec
linter/default-rules/pydantic/types.py     1.00      2.6±0.01ms     9.7 MB/sec    1.01      2.6±0.03ms     9.6 MB/sec

Windows

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.00     10.1±0.12ms     4.0 MB/sec    1.02     10.3±0.19ms     3.9 MB/sec
formatter/numpy/ctypeslib.py               1.01  1963.8±38.18µs     8.5 MB/sec    1.00  1951.4±34.30µs     8.5 MB/sec
formatter/numpy/globals.py                 1.02    212.5±6.10µs    13.9 MB/sec    1.00    208.6±9.56µs    14.1 MB/sec
formatter/pydantic/types.py                1.00      4.3±0.07ms     5.9 MB/sec    1.01      4.3±0.08ms     5.9 MB/sec
linter/all-rules/large/dataset.py          1.00     13.9±0.25ms     2.9 MB/sec    1.00     13.9±0.18ms     2.9 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      3.6±0.04ms     4.6 MB/sec    1.00      3.6±0.06ms     4.6 MB/sec
linter/all-rules/numpy/globals.py          1.00    436.0±5.09µs     6.8 MB/sec    1.01   438.7±11.52µs     6.7 MB/sec
linter/all-rules/pydantic/types.py         1.01      6.2±0.10ms     4.1 MB/sec    1.00      6.2±0.09ms     4.1 MB/sec
linter/default-rules/large/dataset.py      1.00      7.5±0.09ms     5.4 MB/sec    1.02      7.7±0.09ms     5.3 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00  1514.2±19.00µs    11.0 MB/sec    1.03  1554.5±23.29µs    10.7 MB/sec
linter/default-rules/numpy/globals.py      1.01    172.1±5.44µs    17.1 MB/sec    1.00    170.8±2.70µs    17.3 MB/sec
linter/default-rules/pydantic/types.py     1.00      3.3±0.04ms     7.8 MB/sec    1.01      3.3±0.05ms     7.7 MB/sec

@konstin konstin merged commit 9063f45 into main Jul 31, 2023
@konstin konstin deleted the fix_raw_tripled_quoted_string branch July 31, 2023 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants